package idea.think.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class IT_sql extends SQLiteOpenHelper{

	private static final String DATABASE_NAME = "IDEA.db";
	private static final int DATABASE_VERSION = 1;
	public static final String IDEA_TBL = "IDEAADD";
	public static final String CATEGORY_TBL = "CATEGORY";
	
	public IT_sql(Context context){
		super(context, DATABASE_NAME, null, DATABASE_VERSION);		
	}
		
	@Override
	public void onCreate(SQLiteDatabase db) {		
		db.execSQL("CREATE TABLE " + CATEGORY_TBL + "(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
				"catename TEXT);");
		db.execSQL("CREATE TABLE " + IDEA_TBL + "(_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
				"catename TEXT, idea1 TEXT, idea2 TEXT, idea3 TEXT, result TEXT);");
	}

	@Override
	public void onOpen(SQLiteDatabase db) {		
		super.onOpen(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if(oldVersion < newVersion)
			this.onCreate(db);
	}
}
